<!DOCTYPE html>
<html lang='zh-CN'>
<head>
 <meta charset='utf-8'>
 <meta content='IE=edge' http-equiv='X-UA-Compatible'>
 <title>demo</title>
 <script src="./js/lib.js" type="text/javascript"></script>
 <script src="./js/commons.js" type="text/javascript"></script>
</head>

<body>
<form method="post" class="form-x form-auto">
    上传用户头像：
	<input size="100" type="file" class="J_upload" />
</form>
<br>
上传结果：
<img id="img_place" src="" />
<hr>
普通请求：
<br>
<select id="methodSelects">
  <option selected="selected" value="GET">GET</option>
  <option value="POST">POST</option>
</select>
<input id="requrl" size="30" value="/demo/user/1000">
<input id="btn001" type="button" value="请求" />
<br>
<textarea id="textarea001" rows="10" cols="60">结果</textarea>
</body>

<script type="text/javascript">
$(function(){
	var $fileInput = $('.J_upload');
    $fileInput.ajaxUploader({
      action_url: './demo/user/upload',
      input_name: 'file',
      onSubmit: function(id, fileName){},
      onFinish: function(url){
    	$("#img_place").attr("src",url);
     }
   });
    
   $("#btn001").on('click',function(){  
	   var url = $('#requrl').val(),method = $("#methodSelects").val();
	   $.ajax({
		    url:url,
		    type:method,
		    dataType:'json', 
		    success:function(data,textStatus,jqXHR){
		       $("#textarea001").val(JSON.stringify(data) );
		    },
		    error:function(xhr,textStatus){
		        console.log('错误')
		        console.log(xhr)
		        console.log(textStatus)
		    }
		})
   });
});
</script>
</html>